require 'rubygems'
require_gem 'RedCloth'

cdocs = 'chipmunk-docs'

rc_cdocs = RedCloth.new(File.read(cdocs + '.textile'))

html_cdocs = <<HTML
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
		<head>
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
			<title>Chipmunk Game Dynamics Documentation</title>
						<style type="text/css">
							h1 {
									text-align: center;
									font-size: 300%;
							}
					
							h2, h3 {
									background-color: BurlyWood;
									padding: 3px;
							}
					
							p {
									margin-left: 1em;
							}
					
							p.expl {
									margin-left: 2em;
							}
					
							pre {
									background-color: lightGrey;
									padding: 3px;
									margin-left: 1em;
							}
					</style>
		</head>
		<body>
			#{rc_cdocs.to_html}
		</body>
	</html>
HTML

File.open(cdocs + '.html', 'w') do|f|
	f.write html_cdocs
end

Kernel.system('rdoc doc_dummy.rb')